﻿<template>
  <div class="person1" style="width:99%;margin-top:-25px;">
    <!-- 查询条件 -->
    <div class="query-box">
      <el-form :model="dataForm" status-icon ref="dataForm">
        <el-row>
          <el-col :span="4">
            <el-form-item label prop="userName">
              <el-input v-model="dataForm.userName" placeholder="请输入用户名">
                <template slot="prepend">用户名</template>
              </el-input>
            </el-form-item>
          </el-col>

          <el-col :span="4">
            <el-form-item label prop="duty">
              <div class="depart-box">
                <el-input v-model="dataForm.schoolDictName" placeholder="请输入学校名称">
                  <template slot="prepend">学校名称</template>
                </el-input>
              </div>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label prop="contact">
              <el-input v-model="dataForm.schoolDictId" placeholder="请输入学校编码">
                <template slot="prepend">学校编码</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label prop="contact">
              <el-input v-model="dataForm.contact" placeholder="请输入联系人">
                <template slot="prepend">联系人</template>
              </el-input>
            </el-form-item>
          </el-col>
        </el-row>
        <el-row>
          <el-col :span="4">
            <el-form-item label prop="phone">
              <el-input v-model="dataForm.phone" placeholder="请输入联系电话">
                <template slot="prepend">联系电话</template>
              </el-input>
            </el-form-item>
          </el-col>
          <el-col :span="4">
            <el-form-item label prop="accountStatus">
              <div class="depart-box">
                <div class="slect-title">状态</div>
                <el-select v-model="dataForm.userStatus" clearable>
                  <el-option
                    v-for="item in accountStatus"
                    :key="item.key"
                    :label="item.value"
                    :value="item.key"
                  ></el-option>
                </el-select>
              </div>
            </el-form-item>
          </el-col>
        </el-row>
      </el-form>
      <div class="from-btns">
        <kt-button :label="$t('action.reset')" perms="true" type="primary" @click="resetForm()" />
        <kt-button :label="$t('action.search')" perms="true" @click="searchForm" />
      </div>
    </div>
    <!-- 新增用户,导出按钮 -->
    <div class="add-btns">
      <kt-button
        :label="$t('action.add')"
        perms="Organization:Person:add"
        type="primary"
        @click="handleAdd"
      />
      <kt-button
        :label="$t('action.exportExcel')"
        perms="Organization:Person:exportExcel"
        @click="exportPerson"
        type="primary"
      />
    </div>
    <!--表格内容栏-->
    <crm-table
      class="table-width"
      schoolAccountMange
      permsEdit="Organization:Person:edit"
      permsDeletePartment="Organization:Person:deletePartment"
      permsResetPass="Organization:Person:resetPass"
      permsRelationSchool="Organization:Person:resetPass"
      permsBind="Organization:Person:resetPass"
      :data="pageResult"
      :columns="columns"
      @findPage="findPage"
      @handleEdit="handleEdit"
      @handleResetpass="handleResetpass"
      @changeSwitch="changeSwitch"
      :loading="loading"
      @handleRelationSchool="handleRelationSchool"
    ></crm-table>

    <!--新增编辑界面-->
    <el-dialog
      class="add-pop personBox"
      :title="operation ? '新增学校账户' : '编辑'"
      width="30%"
      :visible.sync="dialogVisible"
      :close-on-click-modal="false"
    >
      <el-form
        :model="dataFormAdd"
        label-width="100px"
        :rules="operation?dataFormRules:dataFormRulesEdit"
        ref="dataFormAdd"
        :size="size"
        label-position="right"
      >
        <el-form-item label="用户名" prop="userName">
          <el-input
            v-model="dataFormAdd.userName"
            :disabled="operation ? false : true"
            placeholder="请输入"
            auto-complete="off"
          ></el-input>
        </el-form-item>
        <el-form-item label="联系人" prop="contact">
          <el-input v-model="dataFormAdd.contact" placeholder="请输入" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="联系电话" prop="phone">
          <el-input v-model="dataFormAdd.phone" placeholder="请输入" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="职务" prop="duty">
          <el-input v-model="dataFormAdd.duty" placeholder="请输入" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item label="角色类型" prop="roleId">
          <el-select v-model="dataFormAdd.roleId" filterable clearable placeholder="请选择角色类型">
            <el-option v-for="item in roles" :key="item.id" :label="item.roleName" :value="item.id"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" @click.native="dialogVisible = false">
          {{
          $t("action.cancel")
          }}
        </el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="submitForm"
          v-if="!dataFormAdd.id"
          :loading="editLoading"
        >{{ $t("action.submit") }}</el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="submitFormEdit"
          v-if="dataFormAdd.id"
          :loading="editLoading"
        >{{ $t("action.submit") }}</el-button>
      </div>
    </el-dialog>
    <!-- 重置密码 -->
    <el-dialog
      class="resetpassword"
      title="重置密码"
      width="30%"
      :visible.sync="resetVisible"
      :close-on-click-modal="false"
    >
      <el-form label-width="110px" :rules="dataFormRules" ref="password" :model="dataFormAdd">
        <el-form-item label="用户名" prop="userName">
          <el-input v-model="dataFormAdd.userName" :disabled="true" auto-complete="off"></el-input>
        </el-form-item>
        <el-form-item class="resetpassword-pass" label="密码" prop="resetpassword">
          <el-input
            v-model="dataFormAdd.userPassword"
            type="text"
            auto-complete="off"
            style="width: 50%;margin-right: 10%;margin-left: 1%"
          ></el-input>
          <kt-button
            :label="$t('action.autopassword')"
            @click="autopassword"
            perms="Organization:Person:resetPass"
            type="primary"
          />
        </el-form-item>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" @click.native="resetVisible = false">
          {{
          $t("action.cancel")
          }}
        </el-button>
        <el-button
          :size="size"
          type="primary"
          @click.native="resetPwd"
          :loading="editLoading"
        >{{ $t("action.submit") }}</el-button>
      </div>
    </el-dialog>
    <!--关联学校-->
    <el-dialog
      title="关联学校"
      width="45%"
      :visible.sync="schoolAddVisible"
      :close-on-click-modal="false"
      :before-close="CancelAddPopSelect"
    >
      <el-form
        :model="schoolAdd"
        :rules="dataFormRules"
        ref="dataFormAdd"
        :size="size"
        label-position="right"
      >
        <el-row style="margin-bottom:20px">
          <el-col :span="10">
            <div class="depart-box">
              <div class="slect-title" style="line-height: 40px;">学校编码：</div>
              <el-select filterable clearable v-model="schoolAdd.schoolCode" placeholder="请选择">
                <el-option
                  v-for="item in school_option"
                  :key="item.schoolCode"
                  :label="item.schoolCode"
                  :value="item.schoolCode"
                >{{ item.schoolCode }}</el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="11">
            <div class="depart-box">
              <div class="slect-title" style="line-height: 40px;margin-left:30px">学校名称：</div>
              <el-select filterable clearable v-model="schoolAdd.schoolName" placeholder="请选择">
                <el-option
                  v-for="item in school_option"
                  :key="item.schoolName"
                  :label="item.schoolName"
                  :value="item.schoolName"
                >{{ item.schoolName }}</el-option>
              </el-select>
            </div>
          </el-col>
          <el-col :span="2">
            <el-button type="primary" @click="searchCenterList">查询</el-button>
          </el-col>
        </el-row>
        <Crm-table
          associationSchoolA
          :border="true"
          :showBatchDelete="false"
          class="table-width"
          permsAdd="Organization:TripartiteMange:AssociationSchoolA"
          width="400"
          permsSee="true"
          @handleSeeA="handleSeeA"
          :data="pageResultA"
          :columns="columnsA"
          :loading="loading"
          @findPage="findPage2"
        ></Crm-table>
        <h1 class="columnsA-title">已选学校</h1>
        <Crm-table
          :border="true"
          associationSchoolB
          :showBatchDelete="false"
          class="table-width"
          permsDelete="Organization:TripartiteMange:AssociationSchoolB"
          width="400"
          permsSee="true"
          @handleSeeB="handleSeeB"
          :data="pageResultB"
          :columns="columnsA"
          :loading="loading"
          style="margin-bottom:20px;"
          :order="false"
        ></Crm-table>
      </el-form>
      <div slot="footer" class="dialog-footer">
        <el-button :size="size" @click="CancelAddPopSelect">取 消</el-button>
        <el-button type="primary" :loading="editLoading" :size="size" @click="SubmitAddPopSelect">保存</el-button>
      </div>
    </el-dialog>
  </div>
</template>
<script>
import PopupTreeInput from "@/components/PopupTreeInput";
import KtButton from "@/views/Core/KtButton";
import CrmTable from "@/views/Core/CrmTable";
import QueryBox from "@/views/Core/QueryBox";
import CrmSwitch from "@/views/Core/CrmSwitch";
import axios from "axios";
import { baseUrl } from "@/utils/global";
import { isMobile } from "@/utils/validate";
export default {
  name: "Person",
  components: {
    PopupTreeInput,
    CrmTable,
    KtButton,
    QueryBox,
    CrmSwitch
  },
  data() {
    return {
      size: "small",
      filters: {
        name: ""
      },
      dataForm: {
        // oneLevelDeptId:'',
        // twoLevelDeptId:'',
        // threeLevelDeptId:''
      },
      exportPersonUrl: baseUrl + "/frontUserManager/export", //导出地址
      resetpassword: "",
      page: "person",
      columns: [
        { type: "index", label: "序号", minWidth: 50 },
        { prop: "userName", label: "用户名", minWidth: 80 },
        { prop: "contact", label: "联系人", minWidth: 100 },
        { prop: "roleName", label: "角色类型", minWidth: 100 },
        { prop: "phone", label: "联系电话", minWidth: 100 },
        { prop: "duty", label: "职务", minWidth: 100 },
        { prop: "schoolDictIdName", label: "学校编码", minWidth: 100 },
        { prop: "schoolDictName", label: "学校名称", minWidth: 100 }
      ],
      columnsA: [
        { type: "index", label: "序号", minWidth: 50 },
        { prop: "schoolCode", label: "学校编码", minWidth: 100 },
        { prop: "schoolName", label: "学校名称", minWidth: 100 }
      ],
      pageRequest: { pageNum: 1, pageSize: 10 },
      pageResult: {
        content: [],
        totalSize: ""
      },
      operation: false, // true:新增, false:编辑
      dialogVisible: false, // 新增编辑界面是否显示
      // managerAddVisible: false, //绑定大区经理显示界面
      editLoading: false,
      loading: false, // 加载标识
      resetVisible: false,
      schoolAddVisible: false,
      roles: [],
      // resetpassForm:pageResult,
      dataFormRules: {
        userName: [
          { required: true, message: "请输入用户名", trigger: "blur" }
        ],
        roleId: [
          { required: true, message: "请输入角色类型", trigger: "blur" }
        ],
        contact: [{ required: true, message: "请输入联系人", trigger: "blur" }],
        phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
        duty: [{ required: true, message: "请选择职务", trigger: "blur" }]
      },
      // 编辑  角色类型
      dataFormRulesEdit: {
        userName: [
          { required: false, message: "请输入用户名", trigger: "blur" }
        ],
        roleId: [
          { required: true, message: "请输入角色类型", trigger: "blur" }
        ],
        contact: [{ required: true, message: "请输入联系人", trigger: "blur" }],
        phone: [{ required: true, message: "请输入联系电话", trigger: "blur" }],
        duty: [{ required: true, message: "请选择职务", trigger: "blur" }]
      },
      // 新增编辑界面数据
      dataFormAdd: {
        userName: "",
        realName: "",
        oneLevelDeptId: "",
        twoLevelDeptId: "",
        threeLevelDeptId: "",
        roleId: "",
        phone: "",
        email: "",
        demoAccount: "",
        accountStatus: "",
        duty: "",
        acccountPassword: "",
        userType: "",
        isControlResource: "",

        contact: ""
      },
      deptData: [],
      deptTreeProps: {
        label: "name",
        children: "children"
      },
      accountStatus: [], //状态下拉框
      duty: [], //职务下拉框
      isControlResource: [
        {
          value: "是",
          key: "1"
        },
        {
          value: "否",
          key: "2"
        }
      ],
      userDerpatName: "",
      // managerAdd: {
      //   departmentId: ""
      // },
      schoolAdd: {
        schoolCode: "",
        schoolName: ""
      },
      userName: [],
      departId_option: [],
      pageResultA: {
        content: []
      },
      pageResultB: {
        content: []
      },
      school_option: {},
      SubmitAddPopSelectData: {
        id: "",
        schoolId: []
      },
      SubmitAddPopSelectDataId: ""
    };
  },
  methods: {
    //获取下拉框
    findDown: function() {
      this.queryRole()
      this.$api.dropdown.accountStatus().then(res => {
        this.accountStatus = res.keyValueList;
      });
      this.$api.dropdown.systemDuty().then(res => {
        this.duty = res.keyValueList;
      });
      this.$api.dropdown.users({ userType: 3, deptType: 4 }).then(res => {
        if (res.result == 1) {
          this.userName = res.userInfoList;
        }
      });
      this.$api.dropdown.deptLevel3().then(res => {
        this.departId_option = res.departmentInfoList;
      });
      // 获取学校
      this.$api.oem.schoolList().then(res => {
        this.school_option = res.data;
      });
    },
    // 获取分页数据
    findPage: function(data) {
      setTimeout(
        function() {
          if (data !== null) {
            this.loading = true;
            this.pageRequest = data.pageRequest;
          }
          this.dataForm.pageSize = this.pageRequest.pageSize;
          this.dataForm.pageNum = this.pageRequest.pageNum;
          this.dataForm.userType = 2;
          this.$api.person
            .findFontPage(this.dataForm)
            .then(res => {
              if (res.result == 2) {
                this.$message({
                  message: res.msg,
                  type: "error"
                });
              } else {
                this.pageResult.content = res.data;
                this.pageResult.totalSize = res.total;
                this.loading = false;
                this.pageResult.content.forEach(item => {
                  if (item.schoolDictId) {
                    item.schoolDictId
                      .split(",")
                      .forEach((schoolDictIdItem, index) => {
                        if (this.school_option.length != 0) {
                          this.school_option.forEach(SchoolItem => {
                            if (SchoolItem.id == schoolDictIdItem) {
                              item.schoolDictIdName = SchoolItem.schoolCode;
                            }
                          });
                        }
                      });
                  }

                  item.isControlResource = JSON.stringify(
                    item.isControlResource
                  );
                  // 大区经理转义
                  let userName = JSON.parse(
                    localStorage.getItem("mangerUserName")
                  );
                  if (userName) {
                    userName.forEach(userItem => {
                      if (userItem.id == item.systemUserId) {
                        item.systemUserId = userItem.realName;
                      }
                    });
                  }
                });
              }
            })
            .then(data != null ? data.callback : "");
        }.bind(this),
        0
      );
    },
    findPage2(data) {
      if (data !== null) {
        this.loading = true;
        this.pageRequest2 = data.pageRequest;
      }
      this.pageRequest2 = Object.assign({}, this.pageRequest2, this.schoolAdd);
      this.$api.school.schoolDictPageList(this.pageRequest2).then(res => {
        this.loading = false;
        let content = {
          content: res.data,
          totalSize: res.total
        };
        this.pageResultA = content;
        if (this.pageResultB.content.length > 0) {
          this.pageResultB.content.forEach(item => {
            this.pageResultA.content.forEach((j, i) => {
              if (item.id == j.id) {
                this.pageResultA.content.splice(i, 1);
              }
            });
          });
        }
      });
    },
    searchCenterList() {
      this.loading = true;
      this.pageRequest2.pageNum = 1;
      this.findPage2(null);
    },
    handleDeleteSteering: function(params) {
      this.steeringData.isControlBranch = 2;
      this.steeringData.id = params.row.systemUserId;
      this.$confirm("确认删除选中数据吗？", "提示", {
        type: "warning"
      }).then(() => {
        this.$api.student
          .updateIsUserBranchType(this.steeringData)
          .then(res => {
            if (res.result == 1) {
              this.$message({
                message: res.msg,
                type: "success"
              });
              this.findPage(null);
            } else {
              this.$message({
                message: res.msg,
                type: "error"
              });
            }
          });
      });
    },
    handleSeeA(params) {
      if (this.pageResultB.content.length < 1) {
        this.pageResultB.content.push(params.row);
        this.removeObjWithArr(this.pageResultA.content, params.row);
      } else {
        this.$message({
          message: "只能绑定一个学校，请先移除！",
          type: "error"
        });
      }
    },
    removeObjWithArr(_arr, _obj) {
      var length = _arr.length;
      for (var i = 0; i < length; i++) {
        if (this.isObjectValueEqual(_arr[i], _obj)) {
          if (i == 0) {
            _arr.shift(); //删除并返回数组的第一个元素
            return;
          } else if (i == length - 1) {
            _arr.pop(); //删除并返回数组的最后一个元素
            return;
          } else {
            _arr.splice(i, 1); //删除下标为i的元素
            return;
          }
        }
      }
    },
    isObjectValueEqual(a, b) {
      if (typeof a != "object" && typeof b != "object") {
        if (a == b) {
          return true;
        } else {
          return false;
        }
      }
      var aProps = Object.getOwnPropertyNames(a);
      var bProps = Object.getOwnPropertyNames(b);

      if (aProps.length != bProps.length) {
        return false;
      }

      for (var i = 0; i < aProps.length; i++) {
        var propName = aProps[i];

        if (a[propName] !== b[propName]) {
          return false;
        }
      }

      return true;
    },
    handleSeeB(params) {
      this.pageResultA.content.push(params.row);
      this.removeObjWithArr(this.pageResultB.content, params.row);
    },
    // 关闭 学校绑定
    CancelAddPopSelect() {
      this.pageResultB.content.splice(0, 1);
      this.schoolAddVisible = false;
    },
     // 查询角色
    queryRole(){
      // roleType:1 三方、2：学校 3.分中心
      this.$api.role.queryFontRoleList({ userType: 3,roleType:2 }).then(res => {
        this.roles = res.userRoleList;
      });
    },
    // 保存 学校绑定
    SubmitAddPopSelect() {
      this.editLoading = true;
      this.SubmitAddPopSelectData.id = this.SubmitAddPopSelectDataId;
      let branchIds = [];
      this.pageResultB.content.forEach(item => {
        branchIds.push(item.id);
      });
      this.SubmitAddPopSelectData.schoolId = branchIds[0];
      this.$api.person.bindFontSchool(this.SubmitAddPopSelectData).then(res => {
        if (res.result == 1) {
          this.$message({
            message: "绑定成功",
            type: "success"
          });
          this.SteeringPop = false;
          this.schoolAddVisible = false;
          this.SubmitAddPopSelectData.branchIds = [];
          this.findPage(null);
          this.pageResultB.content.splice(0, 1);
        } else {
          this.$message({
            message: res.msg,
            type: "error"
          });
        }
        this.editLoading = false;
      });
    },
    //重置
    resetForm: function() {
      this.dataForm = {};
      this.editLoading = false;
      this.findPage(null);
      this.findDown();
    },
    //查询
    searchForm: function() {
      this.pageRequest.pageNum='1'
      if (this.school_option) {
        this.school_option.forEach(SchoolItem => {
          console.log(SchoolItem);
          if (SchoolItem.schoolCode === this.dataForm.schoolDictId) {
            this.dataForm.schoolDictId = SchoolItem.id;
          }
        });
      }
      this.findPage(null);
    },
    //新增页面展示
    handleAdd: function() {
      this.operation = true;
      this.dialogVisible = true;
      this.dataFormAdd = {
        userName: "",
        contact: "",
        phone: "",
        userStatus: 1,
        // acccountPassword: 111111,
        userType: 2
      };
      this.queryRole()
    },
    //编辑页面展示
    handleEdit: function(params) {
      this.operation = false;
      this.dialogVisible = true;
      this.dataFormAdd = Object.assign({}, params.row);
      this.dataFormAdd.duty = this.dataFormAdd.duty.toString();
      this.changeAddOne(params.row.oneLevelDeptId);
      this.changeAddTwo(params.row.twoLevelDeptId);
      this.changeThreeFile(params.row.threeLevelDeptId);
      this.queryRole()
    },
    //重置密码页面展示
    handleResetpass: function(params) {
      this.resetVisible = true;
      this.dataFormAdd = Object.assign({}, params.row);
    },

    //密码提交
    resetPwd: function() {
      this.$refs.password.validate(valid => {
        if (valid) {
          this.$confirm("确认重置密码吗？", "提示", {}).then(() => {
            this.data = {
              password: this.dataFormAdd.userPassword,
              id: this.dataFormAdd.id
            };
            this.editLoading = true;
            let params = Object.assign({}, this.data);
            this.$api.person.resetFontPwd(params).then(res => {
              this.editLoading = false;
              if (res.result == 1) {
                this.$message({ message: "成功！", type: "success" });
                this.resetVisible = false;
                this.$refs["dataFormAdd"].resetFields();
                this.findPage(null);
              } else {
                this.$message({
                  message: "失败！",
                  type: "error"
                });
              }
              this.findPage(null);
            });
          });
        }
      });
    },
    //新增提交
    submitForm: function() {
      this.$refs.dataFormAdd.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            if (isMobile(this.dataFormAdd.phone)) {
              this.editLoading = true;
              let params = Object.assign({}, this.dataFormAdd);
              this.$api.person.saveFontInfo(params).then(res => {
                this.editLoading = false;
                if (res.result == 1) {
                  this.$message({ message: res.msg, type: "success" });
                  this.dialogVisible = false;
                  this.$refs["dataFormAdd"].resetFields();
                } else {
                  this.$message({
                    message: res.msg,
                    type: "error"
                  });
                }
                this.findPage(null);
              });
            } else {
              this.$message({ message: "请输入正确的手机号！", type: "error" });
            }
          });
        }
      });
    },
    //编辑提交
    submitFormEdit: function() {
      this.$refs.dataFormAdd.validate(valid => {
        if (valid) {
          this.$confirm("确认提交吗？", "提示", {}).then(() => {
            this.editLoading = true;
            let params = Object.assign({}, this.dataFormAdd);
            this.$api.person.editFontInfo(params).then(res => {
              this.editLoading = false;
              if (res.result == 1) {
                this.$message({ message: res.msg, type: "success" });
                this.dialogVisible = false;
                this.$refs["dataFormAdd"].resetFields();
              } else {
                this.$message({
                  message: res.msg,
                  type: "error"
                });
              }
              this.findPage(null);
            });
          });
        }
      });
    },
    // 自动生成密码
    autopassword: function() {
      var password = "";
      var passLength = 8;
      var random = new Array(
        0,
        1,
        2,
        3,
        4,
        5,
        6,
        7,
        8,
        9,
        "A",
        "B",
        "C",
        "D",
        "E",
        "F",
        "G",
        "H",
        "I",
        "J",
        "K",
        "L",
        "M",
        "N",
        "O",
        "P",
        "Q",
        "R",
        "S",
        "T",
        "U",
        "V",
        "W",
        "X",
        "Y",
        "Z"
      );
      //随机数
      for (let i = 0; i < passLength; i++) {
        //循环操作
        var index = Math.floor(Math.random() * 36); //取得随机数的索引（0~35）
        password += random[index];
      }
      this.dataFormAdd.userPassword = password;
    },
    //switch开关
    changeSwitch: function(data) {
      let userId = data.row.id;
      this.$api.person.updateFontStatus({ id: userId }).then(res => {
        if (res.result == 1) {
          this.$message({ message: res.msg, type: "success" });
          this.$refs.dataForm.validate(valid => {
            if (valid) {
              this.data = {
                userName: this.dataForm.userName,
                realName: this.dataForm.realName,
                oneLevelDeptId: this.dataForm.oneLevelDeptId,
                twoLevelDeptId: this.dataForm.twoLevelDeptId,
                threeLevelDeptId: this.dataForm.threeLevelDeptId,
                roleId: this.dataForm.roleId,
                phone: this.dataForm.phone,
                email: this.dataForm.email,
                duty: this.dataForm.duty,
                demoAccount: this.dataForm.demoAccount,
                accountStatus: this.dataForm.accountStatus
              };
              let params = Object.assign({}, this.data, this.pageRequest);
            }
          });
        } else {
          this.$message({ message: res.msg, type: "error" });
        }
      });
    },
    //导出
    exportPerson: function() {
      this.$refs.dataForm.validate(valid => {
        if (valid) {
          this.data = {
            userName: this.dataForm.userName,
            realName: this.dataForm.realName,
            oneLevelDeptId: this.dataForm.oneLevelDeptId,
            twoLevelDeptId: this.dataForm.twoLevelDeptId,
            threeLevelDeptId: this.dataForm.threeLevelDeptId,
            roleId: this.dataForm.roleId,
            phone: this.dataForm.phone,
            email: this.dataForm.email,
            duty: this.dataForm.duty,
            demoAccount: this.dataForm.demoAccount,
            accountStatus: this.dataForm.accountStatus,
            userType: 2
          };
          let params = Object.assign({}, this.data);
          axios({
            method: "get",
            url: this.exportPersonUrl,
            params: params
          }).then(res => {
            window.open(res.request.responseURL);
          });
        }
      });
    },
    // 所属部门搜索
    querySearchAsync3(queryString, callback) {
      let restaurants = [{}];
      let results = "";
      this.$api.dropdown.deptLevel3().then(res => {
        let depatListJson = [];
        for (let i = 0; i < res.departmentInfoList.length; i++) {
          let j = {};
          j.name = res.departmentInfoList[i].deptName;
          j.id = res.departmentInfoList[i].id;
          depatListJson.push(j);
        }
        for (let i of depatListJson) {
          i.value = i.name; //将想要展示的数据作为value
        }
        restaurants = depatListJson;
        results = queryString
          ? restaurants.filter(this.createFilter3(queryString))
          : restaurants;
        callback(results);
      });
    },
    createFilter3(queryString) {
      return restaurant => {
        return (
          restaurant.name.toLowerCase().indexOf(queryString.toLowerCase()) === 0
        );
      };
    },
    handleSelect3(item) {
      // this.queryBox.departmentId = item.id;
    },
    // 打开绑定学校
    handleRelationSchool(params) {
      this.schoolAdd.schoolCode = "";
      this.schoolAdd.schoolName = "";
      var contentDtat = {
        id: "",
        schoolCode: "",
        schoolName: ""
      };
      this.schoolAddVisible = true;
      if (params.row.schoolDictIdName || params.row.schoolDictName) {
        contentDtat.id = params.row.schoolDictId;
        contentDtat.schoolCode = params.row.schoolDictIdName;
        if (this.school_option) {
          this.school_option.forEach(SchoolItem => {
            if (SchoolItem.schoolCode == contentDtat.schoolCode) {
              contentDtat.schoolName = SchoolItem.schoolName;
            }
          });
        }
        this.pageResultB.content.push(contentDtat);
      }

      this.SubmitAddPopSelectDataId = params.row.id;

      this.findPage2(null);
    }
  },
  mounted() {
    this.findDown();
  }
};
</script>
<style>
@import url("../../assets/queryBox.css");
</style>
<style>
.person input::-webkit-outer-spin-button,
.person input::-webkit-inner-spin-button {
  -webkit-appearance: none !important;
  margin: 0;
}
</style>
<style lang="scss">
.person1 .el-dialog__wrapper .el-form-item__content {
  margin-left: 100px;
}
</style>
<style lang="scss">
.columnsA-title {
  margin: 30px;
  font-size: 20px;
  font-weight: bold;
  text-align: left;
}
</style>
